package calorie.com.calorie.adapter;

import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lxh.baselibray.net.ServiceGenerator;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import calorie.com.calorie.R;
import calorie.com.calorie.response.GoodsOrderResponce;

/**
 * Created by chenxi on 2019/4/11.
 */

public class MallWaitSendAdapter extends BaseQuickAdapter<GoodsOrderResponce.DataBean.OrderListBean,BaseViewHolder> {
    public MallWaitSendAdapter(int layoutResId, @Nullable List<GoodsOrderResponce.DataBean.OrderListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsOrderResponce.DataBean.OrderListBean item) {
        ImageView goodsPic = helper.getView(R.id.goods_pic);
        Glide.with(mContext).load(ServiceGenerator.BASE_URL + ":9023/image/"+item.getImgUrl()).into(goodsPic);

        Date date1 = new Date(item.getCreateTime());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        helper.setText(R.id.goods_name,item.getTitle())
                .setText(R.id.goods_price,""+item.getAmount())
                .setText(R.id.goods_create_time, format.format(date1));
        helper.addOnClickListener(R.id.refund_btn);  //点击事件公用一个
        helper.addOnClickListener(R.id.order_wait_send_item);
    }
}
